/**
 */
package de.thwildau.tm.moses.thrift.thrift.impl;

import de.thwildau.tm.moses.thrift.thrift.Annotation;
import de.thwildau.tm.moses.thrift.thrift.AnnotationElement;
import de.thwildau.tm.moses.thrift.thrift.BOOL;
import de.thwildau.tm.moses.thrift.thrift.BaseType;
import de.thwildau.tm.moses.thrift.thrift.BaseTypeRef;
import de.thwildau.tm.moses.thrift.thrift.BooleanRef;
import de.thwildau.tm.moses.thrift.thrift.Const;
import de.thwildau.tm.moses.thrift.thrift.ConstList;
import de.thwildau.tm.moses.thrift.thrift.ConstMap;
import de.thwildau.tm.moses.thrift.thrift.ConstValue;
import de.thwildau.tm.moses.thrift.thrift.ContainerType;
import de.thwildau.tm.moses.thrift.thrift.ContainerTypeRef;
import de.thwildau.tm.moses.thrift.thrift.CppInclude;
import de.thwildau.tm.moses.thrift.thrift.Definition;
import de.thwildau.tm.moses.thrift.thrift.DefinitionRef;
import de.thwildau.tm.moses.thrift.thrift.DefinitionType;
import de.thwildau.tm.moses.thrift.thrift.DoubleRef;
import de.thwildau.tm.moses.thrift.thrift.EnumElement;
import de.thwildau.tm.moses.thrift.thrift.Field;
import de.thwildau.tm.moses.thrift.thrift.FieldType;
import de.thwildau.tm.moses.thrift.thrift.Function;
import de.thwildau.tm.moses.thrift.thrift.FunctionType;
import de.thwildau.tm.moses.thrift.thrift.Header;
import de.thwildau.tm.moses.thrift.thrift.HexRef;
import de.thwildau.tm.moses.thrift.thrift.Include;
import de.thwildau.tm.moses.thrift.thrift.ListType;
import de.thwildau.tm.moses.thrift.thrift.LongRef;
import de.thwildau.tm.moses.thrift.thrift.MapType;
import de.thwildau.tm.moses.thrift.thrift.Namespace;
import de.thwildau.tm.moses.thrift.thrift.NumberRef;
import de.thwildau.tm.moses.thrift.thrift.Senum;
import de.thwildau.tm.moses.thrift.thrift.Service;
import de.thwildau.tm.moses.thrift.thrift.ServiceRef;
import de.thwildau.tm.moses.thrift.thrift.SetType;
import de.thwildau.tm.moses.thrift.thrift.StringRef;
import de.thwildau.tm.moses.thrift.thrift.Struct;
import de.thwildau.tm.moses.thrift.thrift.Thrift;
import de.thwildau.tm.moses.thrift.thrift.ThriftFactory;
import de.thwildau.tm.moses.thrift.thrift.ThriftPackage;
import de.thwildau.tm.moses.thrift.thrift.Throws;
import de.thwildau.tm.moses.thrift.thrift.ThrowsField;
import de.thwildau.tm.moses.thrift.thrift.TypeDef;
import de.thwildau.tm.moses.thrift.thrift.Union;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class ThriftFactoryImpl extends EFactoryImpl implements ThriftFactory
{
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static ThriftFactory init()
  {
    try
    {
      ThriftFactory theThriftFactory = (ThriftFactory)EPackage.Registry.INSTANCE.getEFactory(ThriftPackage.eNS_URI);
      if (theThriftFactory != null)
      {
        return theThriftFactory;
      }
    }
    catch (Exception exception)
    {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new ThriftFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ThriftFactoryImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case ThriftPackage.THRIFT: return createThrift();
      case ThriftPackage.HEADER: return createHeader();
      case ThriftPackage.INCLUDE: return createInclude();
      case ThriftPackage.CPP_INCLUDE: return createCppInclude();
      case ThriftPackage.NAMESPACE: return createNamespace();
      case ThriftPackage.DEFINITION: return createDefinition();
      case ThriftPackage.CONST: return createConst();
      case ThriftPackage.TYPE_DEF: return createTypeDef();
      case ThriftPackage.ANNOTATION: return createAnnotation();
      case ThriftPackage.ANNOTATION_ELEMENT: return createAnnotationElement();
      case ThriftPackage.ENUM: return createEnum();
      case ThriftPackage.ENUM_ELEMENT: return createEnumElement();
      case ThriftPackage.SENUM: return createSenum();
      case ThriftPackage.STRUCT: return createStruct();
      case ThriftPackage.UNION: return createUnion();
      case ThriftPackage.EXCEPTION: return createException();
      case ThriftPackage.SERVICE: return createService();
      case ThriftPackage.SERVICE_REF: return createServiceRef();
      case ThriftPackage.FIELD: return createField();
      case ThriftPackage.FUNCTION: return createFunction();
      case ThriftPackage.FUNCTION_TYPE: return createFunctionType();
      case ThriftPackage.THROWS: return createThrows();
      case ThriftPackage.THROWS_FIELD: return createThrowsField();
      case ThriftPackage.FIELD_TYPE: return createFieldType();
      case ThriftPackage.DEFINITION_TYPE: return createDefinitionType();
      case ThriftPackage.CONTAINER_TYPE: return createContainerType();
      case ThriftPackage.MAP_TYPE: return createMapType();
      case ThriftPackage.SET_TYPE: return createSetType();
      case ThriftPackage.LIST_TYPE: return createListType();
      case ThriftPackage.BASE_TYPE_REF: return createBaseTypeRef();
      case ThriftPackage.CONTAINER_TYPE_REF: return createContainerTypeRef();
      case ThriftPackage.DEFINITION_REF: return createDefinitionRef();
      case ThriftPackage.CONST_VALUE: return createConstValue();
      case ThriftPackage.NUMBER_REF: return createNumberRef();
      case ThriftPackage.HEX_REF: return createHexRef();
      case ThriftPackage.LONG_REF: return createLongRef();
      case ThriftPackage.DOUBLE_REF: return createDoubleRef();
      case ThriftPackage.BOOLEAN_REF: return createBooleanRef();
      case ThriftPackage.STRING_REF: return createStringRef();
      case ThriftPackage.CONST_LIST: return createConstList();
      case ThriftPackage.CONST_MAP: return createConstMap();
      default:
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object createFromString(EDataType eDataType, String initialValue)
  {
    switch (eDataType.getClassifierID())
    {
      case ThriftPackage.BASE_TYPE:
        return createBaseTypeFromString(eDataType, initialValue);
      case ThriftPackage.BOOL:
        return createBOOLFromString(eDataType, initialValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String convertToString(EDataType eDataType, Object instanceValue)
  {
    switch (eDataType.getClassifierID())
    {
      case ThriftPackage.BASE_TYPE:
        return convertBaseTypeToString(eDataType, instanceValue);
      case ThriftPackage.BOOL:
        return convertBOOLToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Thrift createThrift()
  {
    ThriftImpl thrift = new ThriftImpl();
    return thrift;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Header createHeader()
  {
    HeaderImpl header = new HeaderImpl();
    return header;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Include createInclude()
  {
    IncludeImpl include = new IncludeImpl();
    return include;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CppInclude createCppInclude()
  {
    CppIncludeImpl cppInclude = new CppIncludeImpl();
    return cppInclude;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Namespace createNamespace()
  {
    NamespaceImpl namespace = new NamespaceImpl();
    return namespace;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Definition createDefinition()
  {
    DefinitionImpl definition = new DefinitionImpl();
    return definition;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Const createConst()
  {
    ConstImpl const_ = new ConstImpl();
    return const_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TypeDef createTypeDef()
  {
    TypeDefImpl typeDef = new TypeDefImpl();
    return typeDef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Annotation createAnnotation()
  {
    AnnotationImpl annotation = new AnnotationImpl();
    return annotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AnnotationElement createAnnotationElement()
  {
    AnnotationElementImpl annotationElement = new AnnotationElementImpl();
    return annotationElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public de.thwildau.tm.moses.thrift.thrift.Enum createEnum()
  {
    EnumImpl enum_ = new EnumImpl();
    return enum_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EnumElement createEnumElement()
  {
    EnumElementImpl enumElement = new EnumElementImpl();
    return enumElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Senum createSenum()
  {
    SenumImpl senum = new SenumImpl();
    return senum;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Struct createStruct()
  {
    StructImpl struct = new StructImpl();
    return struct;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Union createUnion()
  {
    UnionImpl union = new UnionImpl();
    return union;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public de.thwildau.tm.moses.thrift.thrift.Exception createException()
  {
    ExceptionImpl exception = new ExceptionImpl();
    return exception;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Service createService()
  {
    ServiceImpl service = new ServiceImpl();
    return service;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ServiceRef createServiceRef()
  {
    ServiceRefImpl serviceRef = new ServiceRefImpl();
    return serviceRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Field createField()
  {
    FieldImpl field = new FieldImpl();
    return field;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Function createFunction()
  {
    FunctionImpl function = new FunctionImpl();
    return function;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FunctionType createFunctionType()
  {
    FunctionTypeImpl functionType = new FunctionTypeImpl();
    return functionType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Throws createThrows()
  {
    ThrowsImpl throws_ = new ThrowsImpl();
    return throws_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ThrowsField createThrowsField()
  {
    ThrowsFieldImpl throwsField = new ThrowsFieldImpl();
    return throwsField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FieldType createFieldType()
  {
    FieldTypeImpl fieldType = new FieldTypeImpl();
    return fieldType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DefinitionType createDefinitionType()
  {
    DefinitionTypeImpl definitionType = new DefinitionTypeImpl();
    return definitionType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ContainerType createContainerType()
  {
    ContainerTypeImpl containerType = new ContainerTypeImpl();
    return containerType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MapType createMapType()
  {
    MapTypeImpl mapType = new MapTypeImpl();
    return mapType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SetType createSetType()
  {
    SetTypeImpl setType = new SetTypeImpl();
    return setType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ListType createListType()
  {
    ListTypeImpl listType = new ListTypeImpl();
    return listType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BaseTypeRef createBaseTypeRef()
  {
    BaseTypeRefImpl baseTypeRef = new BaseTypeRefImpl();
    return baseTypeRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ContainerTypeRef createContainerTypeRef()
  {
    ContainerTypeRefImpl containerTypeRef = new ContainerTypeRefImpl();
    return containerTypeRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DefinitionRef createDefinitionRef()
  {
    DefinitionRefImpl definitionRef = new DefinitionRefImpl();
    return definitionRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ConstValue createConstValue()
  {
    ConstValueImpl constValue = new ConstValueImpl();
    return constValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NumberRef createNumberRef()
  {
    NumberRefImpl numberRef = new NumberRefImpl();
    return numberRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HexRef createHexRef()
  {
    HexRefImpl hexRef = new HexRefImpl();
    return hexRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public LongRef createLongRef()
  {
    LongRefImpl longRef = new LongRefImpl();
    return longRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DoubleRef createDoubleRef()
  {
    DoubleRefImpl doubleRef = new DoubleRefImpl();
    return doubleRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BooleanRef createBooleanRef()
  {
    BooleanRefImpl booleanRef = new BooleanRefImpl();
    return booleanRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public StringRef createStringRef()
  {
    StringRefImpl stringRef = new StringRefImpl();
    return stringRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ConstList createConstList()
  {
    ConstListImpl constList = new ConstListImpl();
    return constList;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ConstMap createConstMap()
  {
    ConstMapImpl constMap = new ConstMapImpl();
    return constMap;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BaseType createBaseTypeFromString(EDataType eDataType, String initialValue)
  {
    BaseType result = BaseType.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertBaseTypeToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BOOL createBOOLFromString(EDataType eDataType, String initialValue)
  {
    BOOL result = BOOL.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertBOOLToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ThriftPackage getThriftPackage()
  {
    return (ThriftPackage)getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static ThriftPackage getPackage()
  {
    return ThriftPackage.eINSTANCE;
  }

} //ThriftFactoryImpl
